﻿using System;
using System.Collections.Generic;
using System.Web;
using ihongma.Common;
namespace ihongma.Web.tools
{
    /// <summary>
    /// $codebehindclassname$ 的摘要说明
    /// </summary>
    //[WebService(Namespace = "http://tempuri.org/")]
    //[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class tag : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
       
          
            context.Response.Write("Hello World");
        }
        private void add(HttpContext context)
        {
            string key=context.Request["kdy"].ToString();
             List<Model.tag> taglist;
            if(CacheHelper.Get(key)==null)
            {
                taglist = new List<ihongma.Model.tag>();
            }
            else
            {
                taglist = (List<Model.tag>)CacheHelper.Get(key);
            }
             Model.tag model=new ihongma.Model.tag();
            model.height = DTRequest.GetQueryInt("h");
            model.width = DTRequest.GetQueryInt("w");
            model.x = DTRequest.GetQueryInt("x");
            model.y = DTRequest.GetQueryInt("y");
            model.message = DTRequest.GetQueryString("mes");
            model.photoid = 1+1;
            taglist.Add(model);
            CacheHelper.Insert(key, taglist, 20);
        }
        private void Load(HttpContext context)
        {
            string key = context.Request["kdy"].ToString();
            List<Model.tag> taglist;
            if (CacheHelper.Get(key) == null)
            {
                taglist = new List<ihongma.Model.tag>();
            }
            else
            {
                taglist = (List<Model.tag>)CacheHelper.Get(key);
            }
            Model.tag model = new ihongma.Model.tag();
            model.height = DTRequest.GetQueryInt("h");
            model.width = DTRequest.GetQueryInt("w");
            model.x = DTRequest.GetQueryInt("x");
            model.y = DTRequest.GetQueryInt("y");
            model.message = DTRequest.GetQueryString("mes");
            model.photoid = DTRequest.GetQueryInt("id");
            taglist.Add(model);
           
            CacheHelper.Insert(key, taglist, 20);
        }
        private void Remove(HttpContext context)
        {


           
            string key = context.Request["kdy"].ToString();
            string id = context.Request["id"].ToString();
            List<Model.tag> taglist =(List<Model.tag>)CacheHelper.Get(key);
            foreach (Model.tag t in taglist)
            {
                //if (t == id)
                //{

                //}
            }
            //if ( == null)
            //{
            //    taglist = new List<ihongma.Model.tag>();
            //}
            //else
            //{
            //    taglist = (List<Model.tag>)CacheHelper.Get(key);
            //}
            //Model.tag model = new ihongma.Model.tag();
            //model.height = DTRequest.GetQueryInt("h");
            //model.width = DTRequest.GetQueryInt("w");
            //model.x = DTRequest.GetQueryInt("x");
            //model.y = DTRequest.GetQueryInt("y");
            //model.message = DTRequest.GetQueryString("mes");
            //model.photoid = 1 + 1;
            //taglist.Add(model);
            CacheHelper.Insert(key, taglist, 20);
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}
